package _021_11_17

func checkTwoWord(str1 string, str2 string) int {
	for i := 0; i < len(str1); i++ {
		for j := 0; j < len(str2); j++ {
			if str1[i] == str2[j] {
				return 0
			}
		}
	}
	return len(str1) * len(str2)
}

func _(words []string) int {
	max := 0
	for i := 0; i < len(words)-1; i++ {
		for j := i + 1; j < len(words); j++ {
			temp := checkTwoWord(words[i], words[j])
			if max < temp {
				max = temp
			}
		}
	}

	return max
}

func maxProduct(words []string) int {
	bitmap_int := make([]int, len(words))
	max := 0
	for i := 0; i < len(words); i++ {
		for j := 0; j < len(words[i]); j++ {
			bitmap_int[i] |= 1 << (words[i][j] - 'a')
		}
	}

	for i := 0; i < len(bitmap_int)-1; i++ {
		for j := i + 1; j < len(bitmap_int); j++ {
			if bitmap_int[i]&bitmap_int[j] == 0 {
				if len(words[i])*len(words[j]) > max {
					max = len(words[i]) * len(words[j])
				}
			}
		}
	}

	return max
}
